"""编辑夺宝奇兵"""

# -*- coding: utf-8 -*-
# @Time    : 2022/5/24 16:24
# @Author  : liuzehai~
# @Email   : 1129309473@qq.com
# @File    : sales_duobaoqibing_page.py
from selenium.webdriver.common.by import By
from page.login_page import LoginPage
from selenium import webdriver
from time import sleep
class FixDuoBao(LoginPage):
    loc_cuxi = (By.CSS_SELECTOR, "#menu-ul > li.collapse.lis.ico_2")
    loc_duobao = (By.XPATH, r"//*[@id='menu-ul']/li[2]/ul/li[1]/a")
    loc_fix_btn = (By.XPATH, "//*[@id='listDiv']/table/tbody")
    loc_fix_btn_click = (By.XPATH, "//*[@id='listDiv']/table/tbody/tr[2]/td[8]/a[2]/img")
    loc_input_name_a=(By.XPATH,"/html/body/div[1]/form/table/tbody/tr[1]/td[2]/input")
    loc_input_name_b=(By.XPATH, "/html/body/div[1]/form/table/tbody/tr[1]/td[2]/input")
    loc_sure_btn = (By.XPATH, "/html/body/div[1]/form/table/tbody/tr[11]/td/input[1]")
    loc_input_keys = (By.XPATH, "//*[@id='keyword']")
    loc_search_btn = (By.XPATH, "//*[@id='searchForm']/span[2]/input")
    loc_photo = (By.XPATH, "//*[@id='compareForm']/div/div/a/img")


    def setUp(self) -> None:
        self.driver = webdriver.Chrome()
        self.driver.get("http://192.168.4.54:8081/upload/admin")
    def cuxi(self):
    # 操作方法
        self.driver.find_element(*self.loc_cuxi).click()
        sleep(3)
    def duobao(self):
        self.driver.find_element(*self.loc_duobao).click()
        #退出菜单的frame
        self.driver.switch_to.parent_frame()
        # 切入主界面的frame
        self.driver.switch_to.frame("main-frame")
        #修改夺宝奇兵
    def fix_btn(self):
        self.driver.find_element(*self.loc_fix_btn)
        self.driver.find_element(*self.loc_fix_btn_click).click()
        #输入内容
    def input_name_a(self):
        self.driver.find_element(*self.loc_input_name_a).clear()
        self.driver.find_element(*self.loc_input_name_b).send_keys("夺宝奇奇")
    def sure_btn(self):
        self.driver.find_element(*self.loc_sure_btn).click()
    def get_page(self):
        self.driver.get("http://192.168.4.54:8081/upload/")
    def input_keys(self):
        self.driver.find_element(*self.loc_input_keys).send_keys("毛衣外套")
    def search_btn(self):
        self.driver.find_element(*self.loc_search_btn).click()
    def photo(self):
        self.driver.find_element(*self.loc_photo).click()
        #汇总
    def fixmit(self):
        self.cuxi()
        self.duobao()
        self.fix_btn()
        self.input_name_a()
        self.sure_btn()
        self.get_page()
        self.input_keys()
        self.search_btn()
        self.photo()